/*******************************************************************************
 * Copyright (c) 2011-11-10 @author <a href="mailto:iffiff1@hotmail.com">Tyler Chen</a>.
 * All rights reserved.
 *
 * Contributors:
 *     <a href="mailto:iffiff1@hotmail.com">Tyler Chen</a> - initial API and implementation
 ******************************************************************************/
package com.redhat.auth.ejb.vo;

import java.io.Serializable;

import org.apache.commons.lang.builder.ToStringBuilder;

/**
 * @author <a href="mailto:iffiff1@hotmail.com">Tyler Chen</a> 
 * @since 2011-11-10
 */
public class SecurityStrategyVO implements Serializable {

	private static final long serialVersionUID = -5351311240201268696L;
	public static final int PASSWORD_COMPLEXITY_UNRESTRICTED = 0;
	public static final int PASSWORD_COMPLEXITY_NUMERIC = 1;
	public static final int PASSWORD_COMPLEXITY_LETTER = 2;
	public static final int PASSWORD_COMPLEXITY_NUMERIC_AND_LETTER = 3;
	public static final int PASSWORD_EXPIRED_DAYS_NEVER_EXPIRED = 0;
	public static final int LOGIN_TIMES_UNLIMITED = 0;

	private Long id;
	// 密码最小长度
	private Integer passwordMinLength;

	// 密码复杂度
	private int passwordComplexity;

	// 密码过期天数，密码过期则强制要求修改密码
	private Integer passwordExpiredDays;

	// 尝试登陆次数，为0表示无限制
	private Integer loginTimes;

	// 尝试登陆的时间限制（分钟）
	// 比如若3分钟内，登陆失败5次，则锁定帐户，只有在loginTimes不为0的时候才起作用
	private Integer loginTimesMinuteLimit;

	// 帐户自动解锁的小时数，为0表示手工解锁
	private Integer autoUnlockHours;

	// 是否需要验证码
	private Boolean needCaptcha = true;

	public SecurityStrategyVO() {
		super();
	}

	public SecurityStrategyVO(Long id, Integer passwordMinLength,
			int passwordComplexity, Integer passwordExpiredDays,
			Integer loginTimes, Integer loginTimesMinuteLimit,
			Integer autoUnlockHours, Boolean needCaptcha) {
		this();
		this.id = id;
		this.passwordMinLength = passwordMinLength;
		this.passwordComplexity = passwordComplexity;
		this.passwordExpiredDays = passwordExpiredDays;
		this.loginTimes = loginTimes;
		this.loginTimesMinuteLimit = loginTimesMinuteLimit;
		this.autoUnlockHours = autoUnlockHours;
		this.needCaptcha = needCaptcha;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getPasswordMinLength() {
		return passwordMinLength;
	}

	public void setPasswordMinLength(Integer passwordMinLength) {
		this.passwordMinLength = passwordMinLength;
	}

	public int getPasswordComplexity() {
		return passwordComplexity;
	}

	public void setPasswordComplexity(int passwordComplexity) {
		this.passwordComplexity = passwordComplexity;
	}

	public Integer getPasswordExpiredDays() {
		return passwordExpiredDays;
	}

	public void setPasswordExpiredDays(Integer passwordExpiredDays) {
		this.passwordExpiredDays = passwordExpiredDays;
	}

	public Integer getLoginTimes() {
		return loginTimes;
	}

	public void setLoginTimes(Integer loginTimes) {
		this.loginTimes = loginTimes;
	}

	public Integer getLoginTimesMinuteLimit() {
		return loginTimesMinuteLimit;
	}

	public void setLoginTimesMinuteLimit(Integer loginTimesMinuteLimit) {
		this.loginTimesMinuteLimit = loginTimesMinuteLimit;
	}

	public Integer getAutoUnlockHours() {
		return autoUnlockHours;
	}

	public void setAutoUnlockHours(Integer autoUnlockHours) {
		this.autoUnlockHours = autoUnlockHours;
	}

	public Boolean getNeedCaptcha() {
		return needCaptcha;
	}

	public void setNeedCaptcha(Boolean needCaptcha) {
		this.needCaptcha = needCaptcha;
	}

	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
}
